package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TransprotService;
import com.ruoyi.system.service.ITransprotServiceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物件搬运Controller
 * 
 * @author ruoyi
 * @date 2021-06-17
 */
@RestController
@RequestMapping("/system/service/transport")
public class TransprotServiceController extends BaseController
{
    @Autowired
    private ITransprotServiceService transprotServiceService;

    /**
     * 查询物件搬运列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(TransprotService transprotService)
    {
        startPage();
        List<TransprotService> list = transprotServiceService.selectTransprotServiceList(transprotService);
        return getDataTable(list);
    }

    /**
     * 导出物件搬运列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:export')")
    @Log(title = "物件搬运", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TransprotService transprotService)
    {
        List<TransprotService> list = transprotServiceService.selectTransprotServiceList(transprotService);
        ExcelUtil<TransprotService> util = new ExcelUtil<TransprotService>(TransprotService.class);
        return util.exportExcel(list, "service");
    }

    /**
     * 获取物件搬运详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:service:query')")
    @GetMapping(value = "/{traId}")
    public AjaxResult getInfo(@PathVariable("traId") Long traId)
    {
        return AjaxResult.success(transprotServiceService.selectTransprotServiceById(traId));
    }

    /**
     * 新增物件搬运
     */
//    @PreAuthorize("@ss.hasPermi('system:service:add')")
    @Log(title = "物件搬运", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransprotService transprotService)
    {
        return toAjax(transprotServiceService.insertTransprotService(transprotService));
    }

    /**
     * 修改物件搬运
     */
//    @PreAuthorize("@ss.hasPermi('system:service:edit')")
    @Log(title = "物件搬运", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransprotService transprotService)
    {
        return toAjax(transprotServiceService.updateTransprotService(transprotService));
    }

    /**
     * 删除物件搬运
     */
//    @PreAuthorize("@ss.hasPermi('system:service:remove')")
    @Log(title = "物件搬运", businessType = BusinessType.DELETE)
	@DeleteMapping("/{traIds}")
    public AjaxResult remove(@PathVariable Long[] traIds)
    {
        return toAjax(transprotServiceService.deleteTransprotServiceByIds(traIds));
    }
}
